package com.example.shiro.demo.entity.many;

import lombok.Data;

import javax.persistence.*;
import java.util.List;

/**
 * <Description> <br>
 *
 * @author renweiping<br>
 * @version 1.0<br>
 * @taskId: <br>
 * @createDate 2019/10/14 13:09 <br>
 * @see com.example.shiro.demo <br>
 */
//@Entity
//@Data
public class ExtUser {

    @Id
    private Long id;
    @Column(unique = true)
    private String name;
    private Integer password;




/*
            @JoinTable( // JoinTable所在的一端为多方关系的维护端
            name = "ext_user_role", // 指定中间表名
            joinColumns= {@JoinColumn(name = "user_id")}, // 指定当前表在中间表的外键名称和外键所指向的当前表主键
            inverseJoinColumns= {@JoinColumn(name = "role_id")})// 指定另一方在中间表的外键名称和外键所指向的主键
*/


    @ManyToMany
    @JoinTable(name = "ext_user_role", joinColumns = @JoinColumn(name = "user_id" , referencedColumnName = "id"),
            inverseJoinColumns = @JoinColumn(name = "role_id" , referencedColumnName = "id"))
    private List<ExtRole> roles;


}
